<?php
    include("common/function.php");
    include("../config/config.php");
    check_session();
    
    $lavel1_model = $dbh->query("SELECT * FROM frame_data WHERE lavel='1' AND type <> 'turn'")->fetchAll();
    
?>

<!DOCTYPE html>
<!-- saved from url=(0043)http://temporary.com/admin/index/index.html -->
<html class=" js flexbox canvas canvastext webgl no-touch geolocation postmessage websqldatabase indexeddb hashchange history draganddrop websockets rgba hsla multiplebgs backgroundsize borderimage borderradius boxshadow textshadow opacity cssanimations csscolumns cssgradients cssreflections csstransforms csstransforms3d csstransitions fontface generatedcontent video audio localstorage sessionstorage webworkers applicationcache svg inlinesvg smil svgclippaths" lang="" style=""><!--<![endif]--><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <title>后台管理</title>
        <link rel="icon" type="image/ico" href="/favicon.ico">
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
   
        <!-- vendor css files -->
        <link rel="stylesheet" href="css/bootstrap.min.css">
        <link rel="stylesheet" href="css/font-awesome.min.css">
        <link rel="stylesheet" href="css/jquery.dataTables.min.css">
        <link rel="stylesheet" href="css/datatables.bootstrap.min.css">
        <link rel="stylesheet" href="css/style.css">
        <link rel="stylesheet" href="css/main.css">
        <link rel="stylesheet" href="css/custom.css">
        <link rel="stylesheet" href="css/index.css">
        <link rel="stylesheet" href="/layui/css/layui.css" media="all">
        <!-- vendor css files -->

        <script src="js/jquery-1.8.3.min.js" type="text/javascript"></script>
        <script src="js/jquery.SuperSlide.2.1.1.js"></script>
        <script src="js/uaredirect.js"></script>
        <script type="text/javascript" src="js/reception.js"></script>
        <script type="text/javascript" src="/layer/layer.js"></script>
        <script type="text/javascript" src="/layui/layui.js"></script>
        <!-- project main css files -->


    <style type="text/css">.jqstooltip { position: absolute;left: 0px;top: 0px;visibility: hidden;background: rgb(0, 0, 0) transparent;background-color: rgba(0,0,0,0.6);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000);-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000)";color: white;font: 10px arial, san serif;text-align: left;white-space: nowrap;padding: 5px;border: 1px solid white;z-index: 10000;}.jqsfield { color: white;font: 10px arial, san serif;text-align: left;}</style></head>
    <body id="minovate" class="appWrapper device-lg scheme-default default-scheme-color header-fixed aside-fixed rightbar-hidden">
    <div id="wrap" class="animsition fade-in" style="animation-duration: 1.5s;">


<?php  include("common/head.php") ?>       
<?php  include("common/left.php") ?>

<!--/ CONTROLS Content -->

<section id="content">
    <div class="page page-dashboard">
        <div class="pageheader">

            <!-- <h2>后台主页 <span></span></h2> -->

            <div class="page-bar">

                <ul class="page-breadcrumb">
                    <li>
                        <a href="module/home/index.php"><i class="fa fa-home"></i> 起始页</a>
                    </li>
                </ul>

                <div class="page-toolbar">
                    <a role="button" tabindex="0" class="btn btn-lightred no-border">
                        <i class="fa fa-calendar"></i>&nbsp;&nbsp;<span><?php echo date("Y年m月d日");?></span>
                    </a>
                </div>
            </div>

        </div>
        <div style="overflow: hidden;padding:0 10px 0 10px;">
            <!-- 主导航-->
            <div class="navigation">
                
                <?php 
                    $nav='';
                    foreach ($lavel1_model as $value) {
                        //主模块导航
                        $nav.='
                        <div class="navigation_btn navigation_btn_'.substr($value['module'],strlen($value['module'])-1).'" this_module="'.$value['module'].'" type="'.$value['type'].'">
                            '.$value['module_name'].'
                        </div>
                        ';
                    }
                    $nav.='
                        <div class="navigation_btn_end" this_module="other"></div>
                        ';
                    echo $nav;
                ?>
            </div>
            <!-- 主导航 -->
            <!-- 主模块 -->
            <?php 
                $mod='';
                foreach ($lavel1_model as $value) {
                    switch ($value['type']) {
                        //有子模块的模块
                        case 'module':
                            //主模块框架
                            $mod.='
                            <div class="navigation_module '.$value['module'].'">
                                ';
                            ////////////////子模块//////////////////////
                            //子模块数据
                            $child=$dbh->query("SELECT * FROM frame_data WHERE belong='".$value['module']."' ORDER BY `data_order`")->fetchAll();
                            $mod.='';
                            //子模块导航
                                $mod.='
                                <!-- 子导航-->
                                <div class="navigation1">
                                ';
                                foreach ($child as  $value1) {
                                    $mod.='
                                    <div class="navigation1_btn navigation1_btn_'.substr($value1['module'],strlen($value1['module'])-1).'" this_module="'.$value1['module'].'" >
                                        '.$value1['module_name'].'
                                    </div>
                                    ';
                                }
                                $mod.='
                                    <div class="navigation1_btn_end" ></div></div>
                                <!-- 子导航-->
                                ';
                            //子模块框架
                                $mod.='
                                    <!-- 子模块-->
                                    ';
                                foreach ($child as  $value1) {
                                    $mod.='
                                    <div class="navigation1_module '.$value1['module'].'" type="pic"></div>
                                    ';
                                }
                                $mod.='
                                <!-- 子模块-->
                                ';
                            ////////////////子模块//////////////////////
                            break;
                        //图片模块
                        case 'lunbo':
                        case 'pic_show_1':
                        case 'pic_show_2':
                        case 'pic_show_3':
                            $mod.='
                            <div class="navigation_module '.$value['module'].'" type="pic">
                                ';
                            break;
                        default:
                            break;
                    }
                    $mod.='</div>';
                }

                    echo $mod;
            ?>
            <!-- 主模块 -->
        </div>
        <!-- /row -->
    </section>
    <div class="zhemu">
        <div class="show_div">
            <div id="data_id" style="text-align: center;">

            </div>
            <div class="upload_div">
                <div class="upload_btn">
                    <button type="button" class="layui-btn" id="test1"><i class="layui-icon">&#xe67c;</i>上传图片</button>
                </div>
                <div class="upload_show">
                    <img src="" id="show_pic">
                </div>
            </div>
            <div class="show_item_div">
                <div class="laval_div">
                    <label for="">标题</label>
                </div>
                <div class="input_div">
                    <input type="text" id="upload_title">
                </div>
            </div>
            <div class="show_item_div">
                <div class="laval_div">
                    <label for="">排序</label>
                </div>
                <div class="input_div">
                    <input type="number" id="upload_order">
                </div>
            </div>
            <div class="show_item_div">
                <div class="laval_div">
                    <label for="">跳转地址</label>
                </div>
                <div class="input_div">
                    <input type="text" id="upload_url" placeholder="空置默认为“#”，不做跳转">
                </div>
            </div>
            <div class="show_item_div">
                <div class="laval_div">
                    <label for="">简介</label>
                </div>
                <div class="text_div">
                <textarea name="textareaname" id="content_text" ></textarea>
                </div>
            </div>
            <div class="show_item_div">
                <div class="laval_div">
                </div>
                <div class="input_div">
                    <button class="layui-btn" onclick="save_data()" >立即提交</button>
                    <button class="layui-btn layui-btn-primary" onclick="close_shade()">取消关闭</button>
                </div>
            </div>
        </div>
    </div>
<!--/ CONTENT -->

</body>
<script type="text/javascript">
    //初始状态
    $(".reception_").css("background-color","rgba(255, 255, 255, 0.5)");//左侧导航高亮

    function add_lun(){
        $("#data_id").html("");
        $("#show_pic").attr("src","");
        $("#upload_title").val("");
        $("#upload_order").val("");
        $("#upload_url").val("");
        $("#content_text").val("");
        $(".zhemu").css("display","block");

    }
    function modify_lun(this_){
        var data=this_.split(",");
        $("#data_id").html(data[0]);
        $("#show_pic").attr("src",data[1]);
        $("#upload_title").val(data[2]);
        $("#upload_order").val(data[3]);
        $("#upload_url").val(data[4]);
        $(".zhemu").css("display","block");
    }
    function close_shade(){
        $(".zhemu").css("display","none");
    }

//layui框架上传图片
layui.use('upload', function(){
  var upload = layui.upload;
   
  //执行实例
  var uploadInst = upload.render({
    elem: '#test1', //绑定元素
    url: 'upload.php', //上传接口
    accept: 'image',
    size: 20480,
    before: function(obj){ 
        var index1 = layer.load(
            3,
            {shade: [0.5,'#000'] }
        );
  },
    done: function(res){
        layer.closeAll('loading'); //关闭loading
        if(res.code == 0){
            layer.alert("服务器端出错，请稍后再试！");
        }
        else{
            $("#show_pic").attr("src",res.msg);
        }
    },
    error: function(){
        layer.closeAll('loading'); //关闭loading
    }
  });
});
</script>
<script type="text/javascript" src="js/module.js"></script>
</html>